/*
 * Achieve it All! - Android app to motivate achieving your goals
 * Copyright (C) 2014  Xilconic
 * 
 * This file is part of Achieve it All!.
 *
 * Achieve it All! is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Achieve it All! is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Achieve it All!.  If not, see <http://www.gnu.org/licenses/>
 */
package com.xilconic.achieveitall.domain;

/**
 * Represents the user input data and track record.
 * @author Xilconic
 *
 */
public class UserProfile implements IUser {
	private String userName;
	private long totalAchievementPoints;
	private long currentPointsBudget;
	
	public UserProfile(){
		userName = "";
	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String newUserName) {
		userName = newUserName;		
	}

	public long getAchievementPoints() {
		return totalAchievementPoints;
	}
	
	public void scoreAchievementPoints(int newAchievementPoints) {
		if(newAchievementPoints < 0) 
			throw new IllegalArgumentException("newAchievementPoints cannot be negative.");
		totalAchievementPoints += newAchievementPoints;
		currentPointsBudget += newAchievementPoints;
	}

	/**
	 * A subset of the collected Achievement Points, not yet spent
	 * on anything.
	 * @return The available points to spend.
	 */
	public long getPointsBudget() {
		return currentPointsBudget;
	}

	/**
	 * Spend a number of the collected Achievement Points in other
	 * to pay for something.
	 * @param spentAmmount The number of point payed; Cannot be more than the 
	 *   available points budget.
	 */
	public void spendPoints(int spentAmmount) {
		if(spentAmmount > currentPointsBudget) 
			throw new IllegalArgumentException("spentAmmount cannot be greater then currentPointsBudget.");
		currentPointsBudget -= spentAmmount;
	}

}
